/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idea.sfo.viewer.graphics;


import designersfo.Cons.CellInfo.CellFormat;
import idea.model.qnrlibrary.CustomResponses;
import idea.model.qnrlibrary.DcAttributeGroup;
import idea.model.qnrlibrary.PaperAttributeGroup;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.List;


/**
 *
 * @author renke002
 */
public class ResponseContent extends ContentLayout
{

    /**
     *
     */
    private String label;
    /**
     *
     */
    Drawable responseArea;


    /**
     *
     * @param cResponses
     * @param dcAttrGroup
     * @param paperAttrGroup
     * @param container
     * @param cellFormat
     */
    public ResponseContent(
            List<CustomResponses> cResponses ,
            List<DcAttributeGroup> dcAttrGroup ,
            List<PaperAttributeGroup> paperAttrGroup ,
            Rectangle container ,
            CellFormat cellFormat )
    {
        buildResponseArea(
                cResponses.get( 0 ) ,
                dcAttrGroup.get( 0 ) ,
                paperAttrGroup.get( 0 ) ,
                container ,
                cellFormat );
    }


    /**
     * @param cResponses
     * @param dcAttrGroup
     * @param paperAttrGroup
     * @param container
     * @param cellFormat
     */
    private void buildResponseArea(
            CustomResponses cResponses ,
            DcAttributeGroup dcAttrGroup ,
            PaperAttributeGroup paperAttrGroup ,
            Rectangle container ,
            CellFormat cellFormat )
    {
        this.label = "[...]";

        String pagName = paperAttrGroup.getAgName();
        switch ( pagName )
        {
            case ResponseAreaNames.ANSWER_SEGMENT_6:
                this.responseArea = new AnswerField(
                        cResponses ,
                        dcAttrGroup ,
                        paperAttrGroup ,
                        container ,
                        cellFormat );
                break;
            case ResponseAreaNames.CHECKBOX_ANY_1:
            case ResponseAreaNames.CHECKBOX_NO_HALO_ONE_DEC_1:
            case ResponseAreaNames.CHECKBOX_ONE_1:
            case ResponseAreaNames.CHECKBOX_ONE_ACS_1:
            /*
             * FALL-THROUGH -- Tho in prod we would invoke a different version
             * of the CheckboxField() constructor.
             */
            case ResponseAreaNames.CHECKBOX_ONE_DEC_1:
                this.responseArea = new CheckboxField(
                        cResponses ,
                        dcAttrGroup ,
                        paperAttrGroup ,
                        container ,
                        cellFormat );
                break;
            default:
                this.responseArea = null;
                System.err.println( "Sorry, the option " + pagName
                        + " is not currently supported." );
                break;
        }
    }


    /**
     *
     * @param g2d
     */
    @Override
    public void draw( Graphics2D g2d )
    {
        if ( this.responseArea != null )
        {
            this.responseArea.draw( g2d );
        }
    }


    /**
     *
     * @return
     */
    @Override
    public String getLabel()
    {
        return this.label;
    }

//    /**
//     * 
//     * @param x
//     * @param y 
//     */
//    @Override
//    public void moveTo( int x , int y )
//    {
//        throw new UnsupportedOperationException( "Not supported yet." ); //To change body of generated methods, choose Tools | Templates.
//    }

    public static class ResponseAreaNames
    {

        /**
         *
         */
        public final static String ANSWER_SEGMENT_6 = "ANSWER_SEGMENT_6";
        /**
         *
         */
        public final static String CHECKBOX_ANY_1 = "CHECKBOX_ANY_1";
        public final static String CHECKBOX_NO_HALO_ONE_DEC_1 = "CHECKBOX_NO_HALO_ONE_DEC_1";
        public final static String CHECKBOX_ONE_1 = "CHECKBOX_ONE_1";
        public final static String CHECKBOX_ONE_ACS_1 = "CHECKBOX_ONE_ACS_1";
        public final static String CHECKBOX_ONE_DEC_1 = "CHECKBOX_ONE_DEC_1";
        // DATE_SEGMENT_6
        // EIN_SEGMENT_10
        // WRITE_IN_ANSWER_2
        // WRITE_IN_ANSWER_24
        // WRITE_IN_ANSWER_36
        // ZIP_CODE_SEGMENT_9
    }

}
